package com.haier.cloudremote.adapter;

import java.util.ArrayList;

import com.haier.cloudremote.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CitySpinnerAdapter extends BaseAdapter {

	private ArrayList<String> cities = new ArrayList<String>();
	private LayoutInflater inflater;
	
	public CitySpinnerAdapter(Context context, ArrayList<String> cities) {
		super();
		this.cities = cities;
		inflater = (LayoutInflater) context.getSystemService
				(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return cities.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return cities.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		TextView textView; 
		String city = (String)getItem(position);
		if(convertView==null){
			convertView = inflater.inflate
					(R.layout.listitem, null);
			textView = (TextView)convertView.findViewById(R.id.listitem_textView);
			convertView.setTag(textView);
		}else{
			textView = (TextView)convertView.getTag();
		}
		textView.setText(city);
  	     
//		textView.setHeight(200);
		return convertView;
	}

}
